/**
* @(#)com.pylc.model.dao.impl.testAdminDaoImpl.java
* 
* @date 2012-6-17
*/
package com.pylc.model.dao.impl;

import static org.junit.Assert.*;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.pylc.model.dao.AdminDao;
import com.pylc.model.entity.Admin;

/** 
 * 
 * @author <a href="mailto:yuanyichen@gmail.com">（H0rol4</a>
 * @version 1.0 
 */

public class testAdminDaoImpl {
	
    private AdminDao adminDao = null;

    @Before
    public void before() {
        String[] paths = { "classpath:applicationContext.xml" };
        ApplicationContext ctx = new ClassPathXmlApplicationContext(paths);
        adminDao = (AdminDaoImpl) ctx.getBean("adminDaoImpl");
    }

	@Test
	public void testLoad() {
		Admin admin = adminDao.load(1L);
		System.out.println(admin.getName());		
	}

	@Test
	public void testGetList() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetAll() {
		fail("Not yet implemented");
	}

	@Test
	public void testGetTotalCount() {
		System.out.println( String.valueOf(adminDao.getTotalCount()));
	}

	@Test
	public void testIsUnique() {
		fail("Not yet implemented");
	}

	@Test
	public void testIsExist() {
		Admin admin = new Admin();
		admin.setId(1);
		//adminDao.isExist("id", admin.getId());
	}

	@Test
	public void testSave() throws Exception {
		Admin admin = new Admin();
		admin.setLoginNum(1);
		admin.setName("Chorola");
		admin.setSuper(true);
		admin.setPassword("123");
		admin.setPermission("1234567890");
		SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
		java.util.Date dt= sdf.parse("2005-2-19");
		admin.setLoginTime(new Date());
		adminDao.save(admin);
	}

	@Test
	public void testUpdate() {
		Admin admin = new Admin();
		admin.setId(1);
		admin.setName("Chorola-Updated");
		adminDao.update(admin);
	}
}
